package com.ihm;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.ItemListener;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;

import javax.swing.*;
import javax.swing.border.BevelBorder;

import com.dao.*;
import com.ihm.FenetreModification;

public class FenetreEdition extends JPanel {
	         private JPanel paneltop ;
	         private JPanel paneltrier ;
	         private static JPanel panelmiddle ;
	         private JPanel panelbas ;
	         private JPanel panelbasgauche ;
	         private JPanel panelbasmiddle ;
	         private JPanel panelbasdroite ;
	         private JPanel panelbasmiddlehaut ;
	         private JPanel panelbasmiddlebas ;
	         private JPanel mainpanel ;
	         private JLabel labelcarte ;
	         private JLabel ListeLieu ;
	         private JLabel lieu ;
	         private JLabel trier ;
	         private JComboBox triercombo ;
	         private JLabel labelrecherche ;
	         private JLabel nomdutitre ;
	         private JLabel nomdudescription ;
	         private static JTextField titrenom ;
	         private static JTextField titredescription ;
	         private JButton buttonrecherche ;
	         private JButton buttonannuler ;
	         private static ArrayList<JPanel> listpanel ;
	         private static CartePreparedRequete carteps ;
	         private static FenetreModification fe ;
	         private static ArrayList<String> stringenregistre ;
	         private ArrayList<JPanel> listenregistrepanel ;
	         private static ArrayList<String> listtitre ;
	         private static Integer id_carte ;
	         private int i;
	         private ArrayList<JPanel> listfiltrepanel ;
	         private static FenetreParcour fenetreparcour ;
	         public JPanel getPaneltop() {
				return paneltop;
			}

			public void setPaneltop(JPanel paneltop) {
				this.paneltop = paneltop;
			}

			public JPanel getPaneltrier() {
				return paneltrier;
			}

			public void setPaneltrier(JPanel paneltrier) {
				this.paneltrier = paneltrier;
			}

			public static JPanel getPanelmiddle() {
				return panelmiddle;
			}

			public static void setPanelmiddle(JPanel panelmiddle) {
				FenetreEdition.panelmiddle = panelmiddle;
			}

			public JPanel getPanelbas() {
				return panelbas;
			}

			public void setPanelbas(JPanel panelbas) {
				this.panelbas = panelbas;
			}

			public JPanel getPanelbasgauche() {
				return panelbasgauche;
			}

			public void setPanelbasgauche(JPanel panelbasgauche) {
				this.panelbasgauche = panelbasgauche;
			}

			public JPanel getPanelbasmiddle() {
				return panelbasmiddle;
			}

			public void setPanelbasmiddle(JPanel panelbasmiddle) {
				this.panelbasmiddle = panelbasmiddle;
			}

			public JPanel getPanelbasdroite() {
				return panelbasdroite;
			}

			public void setPanelbasdroite(JPanel panelbasdroite) {
				this.panelbasdroite = panelbasdroite;
			}

			public JPanel getPanelbasmiddlehaut() {
				return panelbasmiddlehaut;
			}

			public void setPanelbasmiddlehaut(JPanel panelbasmiddlehaut) {
				this.panelbasmiddlehaut = panelbasmiddlehaut;
			}

			public JPanel getPanelbasmiddlebas() {
				return panelbasmiddlebas;
			}

			public void setPanelbasmiddlebas(JPanel panelbasmiddlebas) {
				this.panelbasmiddlebas = panelbasmiddlebas;
			}

			public JLabel getLabelcarte() {
				return labelcarte;
			}

			public void setLabelcarte(JLabel labelcarte) {
				this.labelcarte = labelcarte;
			}

			public JLabel getListeLieu() {
				return ListeLieu;
			}

			public void setListeLieu(JLabel listeLieu) {
				ListeLieu = listeLieu;
			}

			public JLabel getLieu() {
				return lieu;
			}

			public void setLieu(JLabel lieu) {
				this.lieu = lieu;
			}

			public JLabel getTrier() {
				return trier;
			}

			public void setTrier(JLabel trier) {
				this.trier = trier;
			}

			public JComboBox getTriercombo() {
				return triercombo;
			}

			public void setTriercombo(JComboBox triercombo) {
				this.triercombo = triercombo;
			}

			public JLabel getLabelrecherche() {
				return labelrecherche;
			}

			public void setLabelrecherche(JLabel labelrecherche) {
				this.labelrecherche = labelrecherche;
			}

			public static JTextField getDateajoute() {
				return titredescription;
			}

			public void setDateajoute(JTextField dateajoute) {
				this.titredescription = dateajoute;
			}

			public JButton getButtonrecherche() {
				return buttonrecherche;
			}

			public void setButtonrecherche(JButton buttonrecherche) {
				this.buttonrecherche = buttonrecherche;
			}

			public static ArrayList<JPanel> getListpanel() {
				return listpanel;
			}

			public static void setListpanel(ArrayList<JPanel> listpanel) {
				FenetreEdition.listpanel = listpanel;
			}

			public static CartePreparedRequete getCarteps() {
				return carteps;
			}

			public static void setCarteps(CartePreparedRequete carteps) {
				FenetreEdition.carteps = carteps;
			}

			public static FenetreModification getFe() {
				return fe;
			}

			public static void setFe(FenetreModification fe) {
				FenetreEdition.fe = fe;
			}

			public static ArrayList<String> getStringenregistre() {
				return stringenregistre;
			}

			public static void setStringenregistre(ArrayList<String> stringenregistre) {
				FenetreEdition.stringenregistre = stringenregistre;
			}

			public ArrayList<JPanel> getListenregistrepanel() {
				return listenregistrepanel;
			}

			public void setListenregistrepanel(ArrayList<JPanel> listenregistrepanel) {
				this.listenregistrepanel = listenregistrepanel;
			}

			public static ArrayList<String> getListtitre() {
				return listtitre;
			}

			public static void setListtitre(ArrayList<String> listtitre) {
				FenetreEdition.listtitre = listtitre;
			}

			public int getI() {
				return i;
			}

			public void setI(int i) {
				this.i = i;
			}

                 
	         public FenetreEdition()
	         {
                  
	             this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
	             createpanel();
	             createcomponent();
	             addcomponent();
                 this.add(mainpanel);
	             id_carte= null ;
	             carteps = new CartePreparedRequete();
	             try {
					carteps.afficher();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	             listpanel = new ArrayList<>();
	             listtitre = new ArrayList<>();
	             stringenregistre = new ArrayList<>();
	             listenregistrepanel = new ArrayList<>();
	             listfiltrepanel = new ArrayList<>();
	             createlist();
	             event();
	             this.setVisible(true);
	         }
	         
	         public void createpanel()
	         {
	        	 paneltop = new JPanel();
	        	 paneltop.setMaximumSize(new Dimension(700,200));
	        	 paneltop.setSize(new Dimension(700,200));
	        	 paneltop.setLayout(new BoxLayout(paneltop,BoxLayout.X_AXIS));
	        	 paneltrier = new JPanel();
	        	 paneltrier.setMaximumSize(new Dimension(700,100));
	        	 paneltrier.setSize(new Dimension(700,100));
	        	 paneltrier.setLayout(new BoxLayout(paneltrier,BoxLayout.X_AXIS));
	        	 panelmiddle = new JPanel();
                 panelmiddle.setMaximumSize(new Dimension(700,500));
                 panelmiddle.setSize(new Dimension(700,500));
	        	 panelmiddle.setLayout(new BoxLayout(panelmiddle,BoxLayout.Y_AXIS));
	        	 panelbas = new JPanel();
	        	 panelbas.setMaximumSize(new Dimension(700,200));
	        	 panelbas.setSize(new Dimension(700,200));
	        	 panelbas.setLayout(new BoxLayout(panelbas,BoxLayout.X_AXIS));
	        	 panelbasgauche = new JPanel();
	        	 panelbasgauche.setMaximumSize(new Dimension(300,200));
	        	 panelbasgauche.setSize(new Dimension(300,200));
	        	 panelbasmiddle = new JPanel();
	        	 panelbasmiddle.setMaximumSize(new Dimension(500,200));
	        	 panelbasmiddle.setSize(new Dimension(500,200));
	        	 panelbasmiddle.setLayout(new BoxLayout(panelbasmiddle,BoxLayout.Y_AXIS));
	        	 panelbasdroite = new JPanel();
	        	 panelbasdroite.setMaximumSize(new Dimension(300,200));
	        	 panelbasdroite.setSize(new Dimension(300,200));
	        	 panelbasmiddlehaut = new JPanel();
	        	 panelbasmiddlehaut.setLayout(new BoxLayout(panelbasmiddlehaut,BoxLayout.X_AXIS));
	        	 panelbasmiddlebas = new JPanel();
	        	 panelbasmiddlebas.setLayout(new BoxLayout(panelbasmiddlebas,BoxLayout.X_AXIS));
	        	 mainpanel = new JPanel();
	        	 mainpanel.setLayout(new BoxLayout(mainpanel,BoxLayout.Y_AXIS));
	         }
	         public void createcomponent()
	         {
	        	 labelcarte = new JLabel("Edition des cartes");
	        	 labelcarte.setFont(new Font("italique",Font.BOLD,20));
	        	 labelcarte.setForeground(Color.GRAY);
//	        	 ListeLieu = new JLabel("");
//	        	 ListeLieu.setFont(new Font("italique",Font.BOLD,20));
	        	 lieu = new JLabel("Liste de tous les lieux");
	        	 lieu.setFont(new Font("italique",Font.BOLD,16));
	        	 trier = new JLabel("Trier par : ");
	        	 triercombo = new JComboBox();
	        	 triercombo.setMaximumSize(new Dimension(80,20));
	        	 triercombo.setSize(new Dimension(80,20));
	        	 triercombo.addItem("A-Z");
	        	 triercombo.addItem("Z-A");
	        	 triercombo.setSelectedIndex(0);
	        	 labelrecherche = new JLabel("RECHERCHE LIEU");
	        	 labelrecherche.setFont(new Font("italique",Font.BOLD,15));
	        	 nomdutitre = new JLabel("Titre : ");
	        	 nomdudescription = new JLabel(" Description : ");
	        	 titrenom = new JTextField();
	        	 titrenom.setMaximumSize(new Dimension(240,20));
	        	 titrenom.setSize(new Dimension(240,20));
	        	 titredescription = new JTextField();
	        	 buttonrecherche = new JButton("Chercher");
	        	 buttonannuler = new JButton("Annuler");
	        	 
	        	  
	         }
	         public static JTextField getTitrenom() {
				return titrenom;
			}

			public static void setTitrenom(JTextField titrenom) {
				FenetreEdition.titrenom = titrenom;
			}

			public static JTextField getTitredescription() {
				return titredescription;
			}

			public static void setTitredescription(JTextField titredescription) {
				FenetreEdition.titredescription = titredescription;
			}

			public void addcomponent()
	         {   paneltop.add(Box.createHorizontalStrut(20));
	        	 paneltop.add(labelcarte);
	        	 paneltop.add(Box.createHorizontalStrut(40));
	        	 //paneltop.add(ListeLieu);
	        	 paneltop.add(Box.createHorizontalGlue());
	        	 paneltrier.add(Box.createHorizontalStrut(20));
	        	 paneltrier.add(lieu);
	        	 paneltrier.add(Box.createHorizontalGlue());
	        	 paneltrier.add(trier);
                         paneltrier.add(Box.createHorizontalStrut(20));
	        	 paneltrier.add(triercombo);
	        	 paneltrier.add(Box.createHorizontalStrut(20));
	        	 panelbas.add(panelbasgauche);
	        	 panelbas.add(panelbasmiddle);
	        	 panelbas.add(panelbasdroite);
	        	 panelbasgauche.add(Box.createVerticalStrut(20));
	        	 panelbasgauche.add(labelrecherche);
	        	 panelbasmiddlehaut.add(nomdutitre);
	        	 panelbasmiddlehaut.add(titrenom);
	        	 panelbasmiddlebas.add(nomdudescription);
	        	 panelbasmiddlebas.add(titredescription);
	        	 panelbasmiddle.add(panelbasmiddlehaut);
	        	 panelbasmiddle.add(panelbasmiddlebas);
	        	 panelbasdroite.add(Box.createHorizontalGlue());
	        	 panelbasdroite.add(buttonrecherche); 
	        	 panelbasdroite.add(Box.createHorizontalStrut(20));
	        	 panelbasdroite.add(buttonannuler);
	        	 //*****************************//
	        	 mainpanel.add(paneltop);
	        	 mainpanel.add(paneltrier);
	        	 mainpanel.add(panelmiddle);
	        	 mainpanel.add(Box.createVerticalGlue());
	        	 mainpanel.add(panelbas);
	     }
             public void createfiltrelist()
             {   if(carteps.getDatefiltrelist().size()>0)
            	 {panelmiddle.removeAll();
            	 listfiltrepanel.clear();
            	 for(int i=0;i<carteps.getDatefiltrelist().size();i++)
            	 {   
            		 {JPanel mainpanel = new JPanel();
            		 JPanel panelhaut = new JPanel();
            		 panelhaut.setLayout(new BoxLayout(panelhaut,BoxLayout.X_AXIS));
            		 JPanel panelbas = new JPanel();
            		 mainpanel.setLayout(new BoxLayout(mainpanel,BoxLayout.Y_AXIS));
            		 mainpanel.setMaximumSize(new Dimension(700,300));
            		 mainpanel.setSize(new Dimension(700,300));
            		 JLabel labeldescription = new JLabel("Description : ");
            		 JTextArea description = new JTextArea();
            		 final String descriptiontext =carteps.getDescriptionfiltre().get(i).toString();  
            		 final String titretext =carteps.getTitrefiltre().get(i).toString();
              		 final String id_carte = carteps.getIdfiltrelist().get(i).toString();
            		 description.setEditable(false);
            		 description.setText(carteps.getDescriptionfiltre().get(i).toString());
            		 JLabel labeltitre = new JLabel("Titre : "+carteps.getTitrefiltre().get(i).toString());
            		 JLabel labeldate = new JLabel("Date : "+carteps.getDatefiltrelist().get(i).toString());
            		 JButton buttonmodifier = new JButton("modifier");
            		 JButton buttonlist = new JButton("liste"); 		
            		 panelhaut.add(labeltitre);
            		 panelhaut.add(Box.createHorizontalStrut(20));
            		 panelhaut.add(labeldate);
            		 panelhaut.add(Box.createHorizontalStrut(20));
            		 panelhaut.add(buttonmodifier);
            		 panelhaut.add(Box.createHorizontalStrut(10));
            		 panelhaut.add(buttonlist);
            		 panelbas.add(labeldescription);
            		 panelbas.add(Box.createHorizontalStrut(150));
            		 panelbas.add(description);
            		 panelbas.add(Box.createHorizontalStrut(150));
            		 mainpanel.add(panelhaut);
            		 mainpanel.add(panelbas);
            		 mainpanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
            		 listfiltrepanel.add(mainpanel);
            		 buttonlist.addMouseListener(new MouseListener(){

						@Override
						public void mouseClicked(MouseEvent arg0) {
							// TODO Auto-generated method stub
						
						}

						@Override
						public void mouseEntered(MouseEvent arg0) {
							// TODO Auto-generated method stub
							
						}

						@Override
						public void mouseExited(MouseEvent arg0) {
							// TODO Auto-generated method stub
							
						}

						@Override
						public void mousePressed(MouseEvent arg0) {
							// TODO Auto-generated method stub
							
						}

						@Override
						public void mouseReleased(MouseEvent arg0) {
							// TODO Auto-generated method stub
							
						}
            			 
            		 });
            		 buttonmodifier.addMouseListener(new MouseListener(){

                         @Override
                         public void mouseClicked(MouseEvent arg0) {
                                 fe = new FenetreModification();
                                 fe.getTextdescription().setText(descriptiontext);
                                 fe.getTexttitre().setText(titretext);
                                 fe.getText_id().setText(id_carte);
                                 fe.setVisible(true);  
                         }

                         @Override
                         public void mouseEntered(MouseEvent arg0) {
                                 // TODO Auto-generated method stub

                         }

                         @Override
                         public void mouseExited(MouseEvent arg0) {
                                 // TODO Auto-generated method stub

                         }

                         @Override
                         public void mousePressed(MouseEvent arg0) {
                                 // TODO Auto-generated method stub

                         }

                         @Override
                         public void mouseReleased(MouseEvent arg0) {
                                 // TODO Auto-generated method stub

                         }
                     	 
                      });
            		 }
            	 }

            	 
            	 for(int i=0;i<listfiltrepanel.size();i++)
            	 {
            		 panelmiddle.add(listfiltrepanel.get(i));
            	 }}
            	 else
            	 {
            		 JOptionPane.showMessageDialog(null,"Il n'y a aucune resultat correspondant");
            	 }
             }
             
public static  void createlist()
             {      listpanel.clear();
            	 for(  int i=0;i<carteps.getDatelist().size();i++)
            	 {   
            		 JPanel mainpanel = new JPanel();
            		 JPanel panelhaut = new JPanel();
            		 panelhaut.setLayout(new BoxLayout(panelhaut,BoxLayout.X_AXIS));
            		 JPanel panelbas = new JPanel();
            		 mainpanel.setLayout(new BoxLayout(mainpanel,BoxLayout.Y_AXIS));
            		 mainpanel.setMaximumSize(new Dimension(700,300));
            		 mainpanel.setSize(new Dimension(700,300));
            		 JLabel labeldescription = new JLabel("Description : ");
            		 JTextArea description = new JTextArea();
            		 description.setEditable(false);
            		 description.setText(carteps.getDescription().get(i).toString());
            		 final String descriptiontext =carteps.getDescription().get(i).toString();  
            		 JLabel labeltitre = new JLabel("Titre : "+carteps.getTitre().get(i).toString());
            		 JLabel labeldate = new JLabel("Date : "+carteps.getDatelist().get(i).toString());
            		 final String titretext =carteps.getTitre().get(i).toString();
              		 final String id_carte = carteps.getIdlist().get(i).toString();
            		 JButton buttonmodifier = new JButton("modifier");
            		 JButton buttonlist = new JButton("liste"); 		
            		 panelhaut.add(labeltitre);
            		 panelhaut.add(Box.createHorizontalStrut(20));
            		 panelhaut.add(labeldate);
            		 panelhaut.add(Box.createHorizontalStrut(20));
            		 panelhaut.add(buttonmodifier);
            		 panelhaut.add(Box.createHorizontalStrut(10));
            		 panelhaut.add(buttonlist);
            		 panelhaut.add(Box.createHorizontalStrut(50));
            		 panelbas.add(labeldescription);
            		 panelbas.add(Box.createHorizontalStrut(150));
            		 panelbas.add(description);
            		 panelbas.add(Box.createHorizontalStrut(150));
            		 mainpanel.add(panelhaut);
            		 mainpanel.add(panelbas);
            		 mainpanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
            		 buttonlist.addMouseListener(new MouseListener(){

						@Override
						public void mouseClicked(MouseEvent arg0) {
							// TODO Auto-generated method stub
							fenetreparcour = new FenetreParcour();
						}

						@Override
						public void mouseEntered(MouseEvent arg0) {
							// TODO Auto-generated method stub
							
						}

						@Override
						public void mouseExited(MouseEvent arg0) {
							// TODO Auto-generated method stub
							
						}

						@Override
						public void mousePressed(MouseEvent arg0) {
							// TODO Auto-generated method stub
							
						}

						@Override
						public void mouseReleased(MouseEvent arg0) {
							// TODO Auto-generated method stub
							
						}
            			 
            		 });
                         buttonmodifier.addMouseListener(new MouseListener(){

                        @Override
                        public void mouseClicked(MouseEvent arg0) {
                                fe = new FenetreModification();
                                fe.getTextdescription().setText(descriptiontext);
                                fe.getTexttitre().setText(titretext);
                                fe.getText_id().setText(id_carte);
                                fe.setVisible(true);  
                        }

                        @Override
                        public void mouseEntered(MouseEvent arg0) {
                                // TODO Auto-generated method stub

                        }

                        @Override
                        public void mouseExited(MouseEvent arg0) {
                                // TODO Auto-generated method stub

                        }

                        @Override
                        public void mousePressed(MouseEvent arg0) {
                                // TODO Auto-generated method stub

                        }

                        @Override
                        public void mouseReleased(MouseEvent arg0) {
                                // TODO Auto-generated method stub

                        }
                    	 
                     });
            		 listtitre.add(carteps.getTitre().get(i).toString());
            		 stringenregistre.add(carteps.getTitre().get(i).toString());
                     listpanel.add(mainpanel);
                 }
            	 for(int i=0;i<listpanel.size();i++)
            	 {
            		 panelmiddle.add(listpanel.get(i));
            	 }
             }
             
             
              public void event()
              {  buttonannuler.addMouseListener(new MouseListener(){

				@Override
				public void mouseClicked(MouseEvent arg0) {
					// TODO Auto-generated method stub
					mainpanel.removeAll();
					listpanel.clear();
					panelmiddle.removeAll();
					panelmiddle.setLayout(new BoxLayout(panelmiddle,BoxLayout.Y_AXIS));
					panelmiddle.setMaximumSize(new Dimension(700,500));
					panelmiddle.setSize(700,500);
					createlist();
				 mainpanel.add(paneltop);
	        	 mainpanel.add(paneltrier);
	        	 mainpanel.add(panelmiddle);
	        	 mainpanel.add(Box.createVerticalGlue());
	        	 mainpanel.add(panelbas);
	        	 setvisible();
				}

				@Override
				public void mouseEntered(MouseEvent arg0) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void mouseExited(MouseEvent arg0) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void mousePressed(MouseEvent arg0) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void mouseReleased(MouseEvent arg0) {
					// TODO Auto-generated method stub
					
				}
            	  
              });
            	 triercombo.addItemListener(new ItemListener(){

					@Override
					public void itemStateChanged(ItemEvent e) {
						// TODO Auto-generated method stub
                            if(e.getStateChange()==ItemEvent.SELECTED)
							{mainpanel.removeAll();
							panelmiddle.setMaximumSize(new Dimension(700,500));
			                 panelmiddle.setSize(new Dimension(700,500));
				        	 panelmiddle.setLayout(new BoxLayout(panelmiddle,BoxLayout.Y_AXIS));
                            	String index =(String)e.getItemSelectable().getSelectedObjects()[0];
							if(index=="A-Z")
							{   
								Collections.sort(listtitre,String.CASE_INSENSITIVE_ORDER);
	                            for(int i=0;i<listtitre.size();i++)
	                            { 
	                            	for(int j=0;j<stringenregistre.size();j++)
	                            	{
	                            		if(stringenregistre.get(j)==listtitre.get(i))
	                            		{
	                            			listenregistrepanel.add(listpanel.get(j));
	                            		}
	                            	}
	                            	}
	                            for(int i=0;i<listenregistrepanel.size();i++)
	                            {
	                            	panelmiddle.add(listenregistrepanel.get(i));
	                            }
							}
	                            else if(index =="Z-A")
	                            {
	                            	Collections.sort(listtitre,String.CASE_INSENSITIVE_ORDER);
	                            	Collections.reverse(listtitre);
	                            	for(int i=0;i<listtitre.size();i++)
		                            { 
		                            	for(int j=0;j<stringenregistre.size();j++)
		                            	{
		                            		if(stringenregistre.get(j)==listtitre.get(i))
		                            		{
		                            			listenregistrepanel.add(listpanel.get(j));
		                            		}
		                            	}
		                            	}
	                            	for(int i=0;i<listenregistrepanel.size();i++)
		                            {
		                            	panelmiddle.add(listenregistrepanel.get(i));
		                            }
	                            }
	                            mainpanel.add(paneltop);
	                        	mainpanel.add(paneltrier);
	                        	mainpanel.add(panelmiddle);
	                        	mainpanel.add(Box.createVerticalGlue());
	                        	mainpanel.add(panelbas);
	                            }

						
						}

            		 
					});
                 buttonrecherche.addMouseListener(new MouseListener(){

					@Override
					public void mouseClicked(MouseEvent arg0) {
						// TODO Auto-generated method stub
						if(!titrenom.getText().toString().isEmpty()||!titredescription.getText().toString().isEmpty())
						{try {
							carteps.afficherfilter();
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
                         mainpanel.removeAll();
						 panelmiddle.setMaximumSize(new Dimension(700,500));
		                 panelmiddle.setSize(new Dimension(700,500));
						 panelmiddle.setLayout(new BoxLayout(panelmiddle,BoxLayout.Y_AXIS));
						 
						 createfiltrelist();
						 mainpanel.add(paneltop);
			        	 mainpanel.add(paneltrier);
			        	 mainpanel.add(panelmiddle);
			        	 mainpanel.add(Box.createVerticalGlue());
			        	 mainpanel.add(panelbas);
						 setvisible();
						}
						else{
							JOptionPane.showMessageDialog(null, "Veuillez remplir un champ");
						}
						 
					}

					@Override
					public void mouseEntered(MouseEvent arg0) {
						// TODO Auto-generated method stub
						
					}

					@Override
					public void mouseExited(MouseEvent arg0) {
						// TODO Auto-generated method stub
						
					}

					@Override
					public void mousePressed(MouseEvent arg0) {
						// TODO Auto-generated method stub
						
					}

					@Override
					public void mouseReleased(MouseEvent arg0) {
						// TODO Auto-generated method stub
						
					}
                	 
                 });
              }
              public void setvisible()
              {
            	  this.setVisible(true);
              }
              public static Integer getId_carte() {
                    return id_carte;
              }

              public static void setId_carte(Integer id_carte) {
                    FenetreEdition.id_carte = id_carte;
              }
             
            
            }

